//
//  SDHSportsPersonalProfile.m
//  SDHSportsNews
//
//  Created by MichaelShan on 2021/3/14.
//

#import "SDHSportsPersonalProfile.h"
#import "SDHSportsNotchScreenUtil.h"
#import "SDHSportsUserModel.h"
#import "SDHSportsDataManager.h"

@interface SDHSportsPersonalProfile ()

@property (weak, nonatomic) IBOutlet UIImageView *imgAvatar;
@property (weak, nonatomic) IBOutlet UILabel *lbName;
@property (weak, nonatomic) IBOutlet UILabel *lbPhone;

@end

@implementation SDHSportsPersonalProfile

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.title = @"Personal Profile";
    
    self.view.backgroundColor = UIColorFromRGB(48, 48, 48);
    [self initUI];
    [self loadData];
}

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    
    self.navigationController.navigationBar.hidden = NO;
}

- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    
    self.navigationController.navigationBar.hidden = YES;
}

- (void)initUI {
    CGFloat statusBarHeight = [[UIApplication sharedApplication] statusBarFrame].size.height;
    CGFloat navHeight = self.navigationController.navigationBar.frame.size.height;
    CGFloat notchHeight = [SDHSportsNotchScreenUtil getIPhoneNotchScreenHeight];
    notchHeight = 0;
    CGFloat posY =  statusBarHeight + navHeight + notchHeight + 70;

    _imgAvatar.image = [UIImage imageNamed:@"touxiang"];
    [_imgAvatar mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.view);
        make.top.mas_equalTo(posY);
        make.width.mas_equalTo(70);
        make.height.mas_equalTo(70);
    }];

    _lbName.textAlignment = NSTextAlignmentCenter;
    [_lbName mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_imgAvatar).offset(-20);
        make.top.equalTo(_imgAvatar.mas_bottom).offset(10);
    }];
    
    _lbPhone.textAlignment = NSTextAlignmentCenter;
    [_lbPhone mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_lbName);
        make.top.equalTo(_lbName.mas_bottom).offset(10);
    }];
    
    _lbName.textColor = [UIColor whiteColor];
    _lbPhone.textColor = [UIColor whiteColor];
}

- (void)loadData {
    SDHSportsUserModel *user = [SDHSportsDataManager sharedManager].user;
    _lbName.text = [NSString stringWithFormat:@"name: %@", user.name];
    _lbPhone.text = [NSString stringWithFormat:@"phone: %@", user.phone];
}

@end
